/*******************************************************************************
 * Copyright:   Copyright (c) 2007. Hisilicon Technologies, CO., LTD. 
 * Version:     V300R001B01
 * Filename:    hisi6810_i2c_reg.h
 * Description: This module defines the I2C register layout.
 * History:
                1.Created by SunShaojie on 2007/09/15
*******************************************************************************/

#ifndef _HISI6810_I2C_REG_H
#define _HISI6810_I2C_REG_H

#ifdef K3_B831_CODE
#define I2C1_REG_BASE  0x300C3000    /*0x101F6000*/
#define I2C2_REG_BASE  0x300C4000    /*0x101F6000*/
#else
#define I2C1_REG_BASE  0x920c3000    /*0x101F6000*/
#define I2C2_REG_BASE  0x920c4000    /*0x101F6000*/
#endif
#define I2C_REG_LENGTH  0x1000

#ifdef __cplusplus
extern "C" {
#endif

// I2C CON register
#define I2C_CON_SLAVEDIS_BITPOS     6
#define I2C_IS_CON_SLAVEDIS         (0x1 << I2C_CON_SLAVEDIS_BITPOS)

#define I2C_CON_RESTARTEN_BITPOS    5
#define I2C_IS_CON_RESTARTEN        (0x1 << I2C_CON_RESTARTEN_BITPOS)

#define I2C_CON_10BMASTER_BITPOS    4
#define I2C_IS_CON_10BMASTER        (0x1 << I2C_CON_10BMASTER_BITPOS)

#define I2C_CON_10BSLAVE_BITPOS     3
#define I2C_IS_CON_10BSLAVE         (0x1 << I2C_CON_10BSLAVE_BITPOS)

#define I2C_CON_SPEED_BITPOS        1
#define I2C_CON_SPEED_BITWIDTH      2
#define I2C_CON_SPEED_BITMASK       (((1<<I2C_CON_SPEED_BITWIDTH)-1)<<I2C_CON_SPEED_BITPOS)
#define I2C_IS_CON_STANDARD_SPEED   (1<<I2C_CON_SPEED_BITPOS)
#define I2C_IS_CON_FAST_SPEED       (2<<I2C_CON_SPEED_BITPOS)
#define I2C_IS_CON_HIGH_SPEED       (3<<I2C_CON_SPEED_BITPOS)

#define I2C_CON_MASTEREN_BITPOS     0
#define I2C_IS_CON_MASTEREN         (0x1 << I2C_CON_MASTEREN_BITPOS)

// I2C INT_STAT register
#define I2C_INTR_GENCALL_BITPOS     11
#define I2C_IS_INTR_GENCALL         (0x1 << I2C_INTR_GENCALL_BITPOS)

#define I2C_INTR_START_BITPOS       10
#define I2C_IS_INTR_START           (0x1 << I2C_INTR_START_BITPOS)

#define I2C_INTR_STOP_BITPOS        9
#define I2C_IS_INTR_STOP            (0x1 << I2C_INTR_STOP_BITPOS)

#define I2C_INTR_ACTIVITY_BITPOS    8
#define I2C_IS_INTR_ACTIVITY        (0x1 << I2C_INTR_ACTIVITY_BITPOS)

#define I2C_INTR_RXDONE_BITPOS      7
#define I2C_IS_INTR_RXDONE          (0x1 << I2C_INTR_RXDONE_BITPOS)

#define I2C_INTR_TXABRT_BITPOS      6
#define I2C_IS_INTR_TXABRT          (0x1 << I2C_INTR_TXABRT_BITPOS)

#define I2C_INTR_RDREQ_BITPOS       5
#define I2C_IS_INTR_RDREQ           (0x1 << I2C_INTR_RDREQ_BITPOS)

#define I2C_INTR_TXEMPTY_BITPOS     4
#define I2C_IS_INTR_TXEMPTY         (0x1 << I2C_INTR_TXEMPTY_BITPOS)

#define I2C_INTR_TXOVER_BITPOS      3
#define I2C_IS_INTR_TXOVER          (0x1 << I2C_INTR_TXOVER_BITPOS)

#define I2C_INTR_RXFULL_BITPOS      2
#define I2C_IS_INTR_RXFULL          (0x1 << I2C_INTR_RXFULL_BITPOS)

#define I2C_INTR_RXOVER_BITPOS      1
#define I2C_IS_INTR_RXOVER          (0x1 << I2C_INTR_RXOVER_BITPOS)

#define I2C_INTR_RXUNDER_BITPOS     0
#define I2C_IS_INTR_RXUNDER         (0x1 << I2C_INTR_RXUNDER_BITPOS)


// I2C TX_ABRT register
#define I2C_ABRT_SLVRD_INTX_BITPOS      15
#define I2C_IS_ABRT_SLVRD_INTX          (0x1 << I2C_ABRT_SLVRD_INTX_BITPOS)

#define I2C_ABRT_SLV_ARBLOST_BITPOS     14
#define I2C_IS_ABRT_SLV_ARBLOST         (0x1 << I2C_ABRT_SLV_ARBLOST_BITPOS)

#define I2C_ABRT_SLVFLUSH_TXFIFO_BITPOS 13
#define I2C_IS_ABRT_SLVFLUSH_TXFIFO     (0x1 << I2C_ABRT_SLVFLUSH_TXFIFO_BITPOS)

#define I2C_ABRT_ARB_LOST_BITPOS        12
#define I2C_IS_ABRT_ARB_LOST            (0x1 << I2C_ABRT_ARB_LOST_BITPOS)

#define I2C_ABRT_MASTER_DIS_BITPOS      11
#define I2C_IS_ABRT_MASTER_DIS          (0x1 << I2C_ABRT_MASTER_DIS_BITPOS)

#define I2C_ABRT_10BRD_NORSTAT_BITPOS   10
#define I2C_IS_ABRT_10BRD_NORSTAT       (0x1 << I2C_ABRT_10BRD_NORSTAT_BITPOS)

#define I2C_ABRT_SBYTE_NORSTAT_BITPOS   9
#define I2C_IS_ABRT_SBYTE_NORSTAT       (0x1 << I2C_ABRT_SBYTE_NORSTAT_BITPOS)

#define I2C_ABRT_HS_NORSTAT_BITPOS      8
#define I2C_IS_ABRT_HS_NORSTAT          (0x1 << I2C_ABRT_HS_NORSTAT_BITPOS)

#define I2C_ABRT_SBYTE_ACKDET_BITPOS    7
#define I2C_IS_ABRT_SBYTE_ACKDET        (0x1 << I2C_ABRT_SBYTE_ACKDET_BITPOS)

#define I2C_ABRT_HS_ACKDET_BITPOS       6
#define I2C_IS_ABRT_HS_ACKDET           (0x1 << I2C_ABRT_HS_ACKDET_BITPOS)

#define I2C_ABRT_GCALL_READ_BITPOS      5
#define I2C_IS_ABRT_GCALL_READ          (0x1 << I2C_ABRT_GCALL_READ_BITPOS)

#define I2C_ABRT_GCALL_NOACK_BITPOS     4
#define I2C_IS_ABRT_GCALL_NOACK         (0x1 << I2C_ABRT_GCALL_NOACK_BITPOS)

#define I2C_ABRT_TXDATA_NOACK_BITPOS    3
#define I2C_IS_ABRT_TXDATA_NOACK        (0x1 << I2C_ABRT_TXDATA_NOACK_BITPOS)

#define I2C_ABRT_10ADDR2_NOACK_BITPOS   2
#define I2C_IS_ABRT_10ADDR2_NOACK       (0x1 << I2C_ABRT_10ADDR2_NOACK_BITPOS)

#define I2C_ABRT_10ADDR1_NOACK_BITPOS   1
#define I2C_IS_ABRT_10ADDR1_NOACK       (0x1 << I2C_ABRT_10ADDR1_NOACK_BITPOS)

#define I2C_ABRT_7BADDR_NOACK_BITPOS    0
#define I2C_IS_ABRT_7BADDR_NOACK        (0x1 << I2C_ABRT_7BADDR_NOACK_BITPOS)


// the define of I2C register 
typedef struct
{
    UINT32 CON;
    UINT32 TAR;
    UINT32 SAR;
    UINT32 HS_MADDR;
    UINT32 DATA_CMD;
    UINT32 SS_HCNT;
    UINT32 SS_LCNT;
    UINT32 FS_HCNT;
    UINT32 FS_LCNT;
    UINT32 HS_HCNT;
    UINT32 HS_LCNT;
    UINT32 INT_STAT;
    UINT32 INT_MASK;
    UINT32 INT_RAWS;
    UINT32 RX_TL;
    UINT32 TX_TL;
    UINT32 INT_CLR;
    UINT32 CRX_UNDER;
    UINT32 CRX_OVER;
    UINT32 CTX_OVER;
    UINT32 CRD_REQ;
    UINT32 CTX_ABRT;
    UINT32 CRX_DONE;
    UINT32 CLR_ACTIVE;
    UINT32 CSTOP_DET;
    UINT32 CSTART_DET;
    UINT32 CGEN_CALL;
    UINT32 ENABLE;
    UINT32 STATUS;
    UINT32 TXFLR;
    UINT32 RXFLR;
    UINT32 Resever;
    UINT32 TX_ABRT;
    UINT32 RX_NACK;
    UINT32 DMA_CR;
    UINT32 DMA_TDLR;
    UINT32 DMA_RDLR;
} USP_I2C_REG, *PUSP_I2C_REG;

//------------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------------

#ifdef __cplusplus
}
#endif

#endif
